package com.ian.offer;

import com.ian.linked.ListNode;

import java.util.Stack;

/**
 * @author zhangyaowen
 * @date 2021/2/21 2:01 下午
 */
public class ReversePrint {
    public int[] reversePrint(ListNode head) {

        Stack<Integer> stack =  new Stack();
        int N = 0;
        while(head!= null){
            stack.push(head.val);
            head = head.next;
            N++;
        }
        int[] ints =new int[N];
        for (int i =0 ;i<N;i++){
            ints[i] = stack.pop();
        }
        return ints;
    }


}
